﻿using System;
using System.Data.SqlClient;

namespace IFD2
{
    public partial class Fares : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["ACL"].ToString().IndexOf("FA2") < 0)
                {
                    Response.Redirect("unauthorized.aspx");
                    return;
                }

                if (Session["ORI"] != null)
                    txtOriAirport.Text = Session["ORI"].ToString();
                if (Session["DES"] != null)
                    txtDesAirport.Text = Session["DES"].ToString();

                lstOpAirline.SelectedValue = Session["AIRLINE"].ToString();

                try
                {
                    lstCurrency.SelectedValue = Session["DEFAULT_CURRENCY"].ToString();
                }
                catch (Exception ex)
                {
                    //Does nothing!
                }
            }
            else
            {
                lblError.Text = "";
            }

            if (lstStatus.Text == "E")
            {
                mvEdit.ActiveViewIndex = 0;
                btnSubmit.Visible = true;
                btnReject.Visible = false;
                butApprove.Visible = false;
                btnBlock.Visible = false;
                butDelete.Visible = true;
            }
            else if (lstStatus.Text == "S")
            {
                mvEdit.ActiveViewIndex = 1;
                btnSubmit.Visible = false;
                btnReject.Visible = true;
                butApprove.Visible = true;
                btnBlock.Visible = false;
                butDelete.Visible = false;
            }
            else if (lstStatus.Text == "A")
            {
                mvEdit.ActiveViewIndex = 1;
                btnSubmit.Visible = false;
                btnReject.Visible = false;
                butApprove.Visible = false;
                btnBlock.Visible = true;
                butDelete.Visible = false;
            }
            else//Locked
            {
                mvEdit.ActiveViewIndex = 1;
                btnSubmit.Visible = false;
                btnReject.Visible = false;
                butApprove.Visible = false;
                btnBlock.Visible = false;
                butDelete.Visible = false;
            }
            //txtDateFrom.Attributes.Add("onclick", "javascript:new Calendar().show(this);");
            //txtDateTo.Attributes.Add("onclick", "javascript:new Calendar().show(this);");
            //txtOpenAdvance.Attributes.Add("onclick", "javascript:new Calendar().show(this);");
            btnSubmit.Attributes.Add("onclick", "javascript:return confirm('Are you sure?');");
            butDelete.Attributes.Add("onclick", "javascript:return confirm('Are you sure?');");
            btnReject.Attributes.Add("onclick", "javascript:return confirm('Are you sure?');");
            butApprove.Attributes.Add("onclick", "javascript:return confirm('You can not modify some of fare information after it was approved! Are you sure to approve it?');");
            btnBlock.Attributes.Add("onclick", "javascript:return confirm('Are you sure?');");
            butAdd.Attributes.Add("onclick", "javascript:return confirm('Are you sure?');");
        }

        protected void lbtnQuery_Click(object sender, EventArgs e)
        {
            //lblError.Text = "";
            //FillData();
            txtOriAirport.Text = txtOriAirport.Text.Trim().ToUpper();
            txtDesAirport.Text = txtDesAirport.Text.Trim().ToUpper();
            Session["ORI"] = txtOriAirport.Text;
            Session["DES"] = txtDesAirport.Text;
            if (chkQopen.Checked)
                chkIsOpen.Checked = true;
            else
                chkIsOpen.Checked = false;
            if (chkQpublic.Checked)
                chkIsPublic.Checked = true;
            else
                chkIsPublic.Checked = false;

            if (lstStatus.Text == "E")
                GridView2.DataBind();
            else
            {
                if (lstStatus.Text == "A")
                {
                    btnReset.Enabled = true;
                    //btnCopyAs.Enabled = true;
                }
                else
                {
                    btnReset.Enabled = false;
                    //btnCopyAs.Enabled = false;
                }
                GridView1.DataBind();
            }
        }

        protected void butDelete_Click(object sender, EventArgs e)
        {
            if (Session["ACL"].ToString().IndexOf("FA3") < 0)
            {
                lblError.Text = "Unauthorized!";
                return;
            }

            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            int ret_code;
            SqlCommand cmd = new SqlCommand();
            lblError.Text = "";

            cmd.CommandText = "bll_fare_delete";
            SqlParameter para = cmd.Parameters.AddWithValue("@code", strArray[0]);
            para = cmd.Parameters.AddWithValue("@airline", Session["AIRLINE"].ToString());
            para = cmd.Parameters.AddWithValue("@user", Session["USER"].ToString());
            para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
            try
            {
                ret_code = TinyDAL.Exec(ref cmd);
                if (ret_code == 0)
                {
                    lblError.Text = "Done.";
                    GridView2.DataBind();
                }
                else
                    lblError.Text = "Error " + ret_code.ToString() + "! Contact system adminstartor!";
            }
            catch (Exception ex)
            {
                if (Application["DEBUG"].ToString() == "1")
                    lblError.Text = ex.Message;
                else
                    lblError.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";
            }

            //FillData();

        }
        protected void butApprove_Click(object sender, EventArgs e)
        {
            if (Session["ACL"].ToString().IndexOf("FA4") < 0)
            {
                lblError.Text = "Unauthorized!";
                return;
            }

            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            int ret_code;
            SqlCommand cmd = new SqlCommand("bll_fare_approve");
            SqlParameter para = cmd.Parameters.AddWithValue("@fare_code", strArray[0]);
            para = cmd.Parameters.AddWithValue("@airline", Session["AIRLINE"].ToString());
            para = cmd.Parameters.AddWithValue("@user", Session["USER"].ToString());
            para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
            try
            {
                ret_code = TinyDAL.Exec(ref cmd);
                if (ret_code == 0)
                {
                    lblError.Text = "Done.";
                    GridView1.DataBind();
                }
                else if (ret_code == 1)
                {
                    lblError.Text = "Fare not found!";
                }
                else if (ret_code == 2)
                {
                    lblError.Text = "Segments mismatched!";
                }
                else if (ret_code == 3)
                {
                    lblError.Text = "Please approve segment price on day 0 first!";
                }
                else if (ret_code == 4)
                {
                    lblError.Text = "Timespan not found!";
                }
                else if (ret_code == 5)
                {
                    lblError.Text = "Approving failed!";
                }
                else
                    lblError.Text = "Error " + ret_code.ToString() + "! Contact system adminstartor!";
            }
            catch (Exception ex)
            {
                if (Application["DEBUG"].ToString() == "1")
                    lblError.Text = ex.Message;
                else
                    lblError.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";
            }

        }
        protected void butAdd_Click(object sender, EventArgs e)
        {
            if (Session["ACL"].ToString().IndexOf("FA3") < 0)
            {
                lblError.Text = "Unauthorized!";
                return;
            }

            //if (txtFareID.Text.IndexOf(",") >= 0)
            //{
            //    lblError.Text = "Fare ID should not include comma( ,)!";
            //    return;
            //}
            //txtFltTypes.Text = txtFltTypes.Text.Trim().ToUpper();
            //if (txtFltTypes.Text.Length == 0)
            //{
            //    lblError.Text = "Invalid flight types!";
            //    return;
            //}
            txtFareID.Text = txtFareID.Text.ToUpper();
            System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[A-Z0-9]+$");
            if (!reg1.IsMatch(txtFareID.Text))
            {
                lblError.Text = "Only english characters or number characters can show in Fare ID!";
                return;
            }
            int ret_code;

            try
            {
                SqlCommand cmd = new SqlCommand("bll_fare_new");
                SqlParameter para = cmd.Parameters.AddWithValue("@code", txtFareID.Text);
                para = cmd.Parameters.AddWithValue("@airline", Session["AIRLINE"].ToString());
                para = cmd.Parameters.AddWithValue("@is_open", chkIsOpen.Checked);
                if (chkIsOpen.Checked)
                    chkQopen.Checked = true;
                else
                    chkQopen.Checked = false;
                para = cmd.Parameters.AddWithValue("@is_public", chkIsPublic.Checked);
                if (chkIsPublic.Checked)
                    chkQpublic.Checked = true;
                else
                    chkQpublic.Checked = false;
                //para = cmd.Parameters.AddWithValue("@flt_types", txtFltTypes.Text);
                //para = cmd.Parameters.AddWithValue("@surcharge_type", lstSurchargeTypes.SelectedValue);
                para = cmd.Parameters.AddWithValue("@op_airline", lstOpAirline.Text);
                para = cmd.Parameters.AddWithValue("@cabin", lstCabin.Text);
                para = cmd.Parameters.AddWithValue("@currency", lstCurrency.Text);
                para = cmd.Parameters.AddWithValue("@agent_rate", Convert.ToSingle(txtAgentRate.Text));
                para = cmd.Parameters.AddWithValue("@agent_policy", txtAgentPolicy.Text);
                para = cmd.Parameters.AddWithValue("@seats_min", txtSeatsFloor.Text);
                para = cmd.Parameters.AddWithValue("@time_limit", txtTimeLimit.Text);
                para = cmd.Parameters.AddWithValue("@seg_total", lstSegTotal.SelectedValue);
                para = cmd.Parameters.AddWithValue("@begin_date", Convert.ToDateTime(txtBeginDate.Text));
                para = cmd.Parameters.AddWithValue("@end_date", Convert.ToDateTime(txtEndDate.Text));
                para = cmd.Parameters.AddWithValue("@fltdate_from", Convert.ToDateTime(txtDateFrom.Text));
                para = cmd.Parameters.AddWithValue("@fltdate_to", Convert.ToDateTime(txtDateTo.Text));
                para = cmd.Parameters.AddWithValue("@open_advance", "-" + txtOpenAdvance.Text);
                para = cmd.Parameters.AddWithValue("@close_advance", "-" + txtCloseAdvance.Text);
                para = cmd.Parameters.AddWithValue("@free_baggage", txtBaggage.Text);
                para = cmd.Parameters.AddWithValue("@chd_baggage", txtChdBag.Text);
                para = cmd.Parameters.AddWithValue("@inf_baggage", txtInfBag.Text);
                para = cmd.Parameters.AddWithValue("@refund_rule", lstRefundRules.SelectedValue);
                //para = cmd.Parameters.AddWithValue("@chg_flt_fee", Convert.ToDecimal(txtChgFltFee.Text));
                //para = cmd.Parameters.AddWithValue("@chg_flt_before", txtChgFltBefore.Text);
                //para = cmd.Parameters.AddWithValue("@chg_name_fee", Convert.ToDecimal(txtChgNameFee.Text));
                //para = cmd.Parameters.AddWithValue("@chg_name_before", txtChgNameBefore.Text);
                //para = cmd.Parameters.AddWithValue("@office", Session["OFFICE"].ToString());
                para = cmd.Parameters.AddWithValue("@user", Session["USER"].ToString());
                para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
                //para = new SqlParameter("@ret_code", SqlDbType.Int);
                //para.Direction = ParameterDirection.Output;
                //cmd.Parameters.Add(para);
                ret_code = TinyDAL.Exec(ref cmd);
                if (ret_code == 0)
                {
                    lblError.Text = "Done.";
                    GridView2.DataBind();
                }
                else if (ret_code == 1)
                    lblError.Text = "Illegal character was found in fare code!";
                else if (ret_code == 2)
                    lblError.Text = "Flight date period is illegal!";
                else if (ret_code == 3)
                    lblError.Text = "Flight date period should be shorter than 6 months!";
                else if (ret_code == 5)
                    lblError.Text = "Airline not found!";
                else if (ret_code == 6)
                    lblError.Text = "Max fare product segments limits to 2!";
                else if (ret_code == 7)
                    lblError.Text = "Adding new fare failed!";
                else
                    lblError.Text = "Error " + ret_code.ToString() + "! Contact system adminstartor!";
            }
            catch (Exception ex)
            {
                if (Application["DEBUG"].ToString() == "1")
                    lblError.Text = ex.Message;
                else
                    lblError.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";
            }

        }

        protected void butRulesText_Click(object sender, EventArgs e)
        {
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            Response.Redirect("FareDescription.aspx?code=" + strArray[0]);

        }
        protected void butAirlines_Click(object sender, EventArgs e)
        {
            //功能取消！
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            Response.Redirect("fare_entities.aspx?code=" + strArray[0]);//airline passed though session!

        }
        protected void butOffices_Click(object sender, EventArgs e)
        {
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            Response.Redirect("FareOffices.aspx?code=" + strArray[0] + "&airline=" + strArray[1]);//airline passed though session!
        }
        protected void butFlights_Click(object sender, EventArgs e)
        {
            //功能取消！
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            Response.Redirect("fare_flights.aspx?code=" + strArray[0]);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Session["ACL"].ToString().IndexOf("FA3") < 0)
            {
                lblError.Text = "Unauthorized!";
                return;
            }
            int ret_value;
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            SqlCommand cmd = new SqlCommand("bll_fare_submit");
            SqlParameter para = cmd.Parameters.AddWithValue("@fare_code", strArray[0]);
            para = cmd.Parameters.AddWithValue("@airline", Session["AIRLINE"].ToString());
            para = cmd.Parameters.AddWithValue("@user", Session["USER"].ToString());
            para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
            try
            {
                ret_value = TinyDAL.Exec(ref cmd);
                if (ret_value == 0)
                {
                    lblError.Text = "Submitted successfully!";
                    GridView2.DataBind();
                }
                else if (ret_value == 1)
                {
                    lblError.Text = "Segments mismatch or not sequential!";
                    GridView2.DataBind();
                }
                else if (ret_value == 2)
                {
                    lblError.Text = "Fare not found or not in editing status!";
                    GridView2.DataBind();
                }
                else if (ret_value == 3)
                {
                    lblError.Text = "Please define unapproved segment price on day 0 first!";
                    GridView2.DataBind();
                }
                else if (ret_value == 4)
                {
                    lblError.Text = "Lost some segments!";
                    GridView2.DataBind();
                }
                else if (ret_value == 5)
                {
                    lblError.Text = "Please input fare rules!";
                    GridView2.DataBind();
                }
                else if (ret_value == 6)
                {
                    lblError.Text = "Please input fare timespan!";
                    GridView2.DataBind();
                }
                else
                {
                    lblError.Text = "Error " + ret_value.ToString() + "! Fare is not OK! Please check segments,fare-stairs and rules!";
                }
            }
            catch (Exception ex)
            {
                if (Application["DEBUG"].ToString() == "1")
                    lblError.Text = ex.Message;
                else
                    lblError.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";
            }

        }
        protected void btnSegments_Click(object sender, EventArgs e)
        {
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            Response.Redirect("FareSegments.aspx?fare_code=" + strArray[0] + "&airline=" + strArray[1] + "&cabin=" + strArray[2] + "&op_airline=" + strArray[3]);
        }
        protected void btnReject_Click(object sender, EventArgs e)
        {
            if (Session["ACL"].ToString().IndexOf("FA4") < 0)
            {
                lblError.Text = "Unauthorized!";
                return;
            }
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            int ret_code;
            SqlCommand cmd = new SqlCommand("bll_fare_reject");
            SqlParameter para = cmd.Parameters.AddWithValue("@fare_code", strArray[0]);
            para = cmd.Parameters.AddWithValue("@airline", Session["AIRLINE"].ToString());
            para = cmd.Parameters.AddWithValue("@user", Session["USER"].ToString());
            para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
            try
            {
                ret_code = TinyDAL.Exec(ref cmd);
                if (ret_code == 0)
                {
                    lblError.Text = "Done.";
                    GridView1.DataBind();
                }
                else
                    lblError.Text = "Error " + ret_code.ToString() + "! Contact system adminstartor!";
            }
            catch (Exception ex)
            {
                if (Application["DEBUG"].ToString() == "1")
                    lblError.Text = ex.Message;
                else
                    lblError.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";
            }

        }
        protected void btnBlock_Click(object sender, EventArgs e)
        {
            if (Session["ACL"].ToString().IndexOf("FA4") < 0)
            {
                lblError.Text = "Unauthorized!";
                return;
            }
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            int ret_code;
            SqlCommand cmd = new SqlCommand("bll_fare_lock");
            SqlParameter para = cmd.Parameters.AddWithValue("@fare_code", strArray[0]);
            para = cmd.Parameters.AddWithValue("@airline", Session["AIRLINE"].ToString());
            para = cmd.Parameters.AddWithValue("@user", Session["USER"].ToString());
            para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
            try
            {
                ret_code = TinyDAL.Exec(ref cmd);
                if (ret_code == 0)
                {
                    lblError.Text = "Done.";
                    GridView1.DataBind();
                }
                else if (ret_code == 1)
                {
                    lblError.Text = "Failed!";
                }
                else
                    lblError.Text = "Error " + ret_code.ToString() + "! Contact system adminstartor!";
            }
            catch (Exception ex)
            {
                if (Application["DEBUG"].ToString() == "1")
                    lblError.Text = ex.Message;
                else
                    lblError.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";
            }

        }
        protected void lstOpAirline_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstCabin.DataBind();
        }
        protected void btnLogs_Click(object sender, EventArgs e)
        {
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            Response.Redirect("FareLog.aspx?code=" + strArray[0]);
        }
        protected void btnReset_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime.Parse(txtBeginDate2.Text);
                DateTime.Parse(txtEndDate2.Text);
            }
            catch
            {
                lblError2.Text = "Invalid date format!";
                return;
            }

            if (Session["ACL"].ToString().IndexOf("FA4") < 0)
            {
                lblError2.Text = "Unauthorized!";
                return;
            }

            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            int ret_code;
            SqlCommand cmd = new SqlCommand("bll_fare_set_valid_period");
            SqlParameter para = cmd.Parameters.AddWithValue("@fare_code", strArray[0]);
            para = cmd.Parameters.AddWithValue("@airline", Session["AIRLINE"].ToString());
            para = cmd.Parameters.AddWithValue("@open_from", txtBeginDate2.Text);
            para = cmd.Parameters.AddWithValue("@open_to", txtEndDate2.Text);
            para = cmd.Parameters.AddWithValue("@user", Session["USER"].ToString());
            para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
            try
            {
                ret_code = TinyDAL.Exec(ref cmd);
                if (ret_code == 0)
                {
                    lblError.Text = "Done.";
                    GridView1.DataBind();
                }
                else if (ret_code == 1)
                {
                    lblError2.Text = "Resetting failed!";
                }
                else
                    lblError2.Text = "Error " + ret_code.ToString() + "! Contact system adminstartor!";
            }
            catch (Exception ex)
            {
                if (Application["DEBUG"].ToString() == "1")
                    lblError2.Text = ex.Message;
                else
                    lblError2.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";
            }
        }
        protected void btnCopyAs_Click(object sender, EventArgs e)
        {
            //有些参数COPY后不好调整，所以能取消此功能！
            return;

            //if (Session["ACL"].ToString().IndexOf("AG2") < 0)
            //{
            //    lblError2.Text = "Unauthorized!";
            //    return;
            //}

            //txtNewFareID.Text = txtNewFareID.Text.ToUpper();
            //System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[A-Z0-9]+$");
            //if (!reg1.IsMatch(txtNewFareID.Text))
            //{
            //    lblError2.Text = "Only english characters or number characters can show in Fare ID!";
            //    return;
            //}

            //string key;
            //string[] strArray;
            //if (Request.Form["KEY"] == null)
            //    return;
            //key = Request.Form["KEY"];
            //strArray = key.Split('|');

            //int ret_code;
            //SqlCommand cmd = new SqlCommand("bll_fare_copy_to_new");
            //SqlParameter para = cmd.Parameters.AddWithValue("@ori_fare", strArray[0]);
            //para = cmd.Parameters.AddWithValue("@airline", Session["AIRLINE"].ToString());
            //para = cmd.Parameters.AddWithValue("@new_fare", txtNewFareID.Text);
            //para = cmd.Parameters.AddWithValue("@user", Session["USER"].ToString());
            //para = cmd.Parameters.AddWithValue("@ip_addr", Request.UserHostAddress.ToString());
            //try
            //{
            //    ret_code = TinyDAL.Exec(ref cmd);
            //    if (ret_code == 0)
            //    {
            //        lblError.Text = "Done.";
            //        GridView1.DataBind();
            //    }
            //    else if (ret_code == 1)
            //    {
            //        lblError2.Text = "Fare not found or not approved!";
            //    }
            //    else if (ret_code == 2)
            //    {
            //        lblError2.Text = "Fare segments not found!";
            //    }
            //    else if (ret_code == 3)
            //    {
            //        lblError2.Text = "Fare prices not found!";
            //    }
            //    else if (ret_code == 4)
            //    {
            //        lblError2.Text = "Fare rules not found!";
            //    }
            //    //else if (ret_code == 5)
            //    //{
            //    //    lblError2.Text = "Fare offices not found!";
            //    //}
            //    else
            //        lblError2.Text = "Error " + ret_code.ToString() + "! Contact system adminstartor!";
            //}
            //catch (Exception ex)
            //{
            //    if (Application["DEBUG"].ToString() == "1")
            //        lblError2.Text = ex.Message;
            //    else
            //        lblError2.Text = "Unexpected error! Please recheck the input/output data first. If the error appears again, contact adminstrator with your operating details please.";
            //}
        }
        protected void lstOpAirline_DataBound(object sender, EventArgs e)
        {
            lstOpAirline.SelectedValue = Session["AIRLINE"].ToString();
        }
        protected void lstRefundRules_SelectedIndexChanged(object sender, EventArgs e)
        {
            grdRefundDetails.DataBind();
        }

        protected void btnTime_Click(object sender, EventArgs e)
        {
            string key;
            string[] strArray;
            if (Request.Form["KEY"] == null)
                return;
            key = Request.Form["KEY"];
            strArray = key.Split('|');

            Response.Redirect("FareTime.aspx?code=" + strArray[0]);
        }
    }
}